package com.csht.facelib.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.csht.facelib.api.FaceSdk;

/**
 * Created by Administrator on 2020/2/3 0003.
 */

public class SpUtils {

    private static SharedPreferences sp() {
        return FaceSdk.getInstance().getContext().getSharedPreferences("LocalImgInfo", Context.MODE_PRIVATE);
    }

    public static void clear() {
        sp().edit().clear().apply();
    }

    public static void setFaceSDKAuthCode(String authCode) {
        sp().edit().putString("FaceSDKAuthCode", authCode).apply();
    }

    public static String getFaceSDKAuthCode() {
        return sp().getString("FaceSDKAuthCode", "");
    }

    public static boolean isQualityControl() {
        return sp().getBoolean("qualityControl", false);
    }

    public static void setQualityControl(boolean qualityControl) {
        sp().edit().putBoolean("qualityControl", qualityControl).apply();
    }

    public static int getDetectDirection() {
        return sp().getInt("detectDirection", 0);
    }

    public static void setDetectDirection(int detectDirection) {
        sp().edit().putInt("detectDirection", detectDirection).apply();
    }

    public static int getFaceDistance() {
        return sp().getInt("faceDistance", 6);
    }

    public static void setFaceDistance(int faceDistance) {
        sp().edit().putInt("faceDistance", faceDistance).apply();
    }

    public static boolean isOpenMirror() {
        return sp().getBoolean("openMirror", false);
    }

    public static void setOpenMirror(boolean openMirror) {
        sp().edit().putBoolean("openMirror", openMirror).apply();
    }

    public static boolean isCameraMirror() {
        return sp().getBoolean("cameraMirror", false);
    }

    public static void setCameraMirror(boolean cameraMirror) {
        sp().edit().putBoolean("cameraMirror", cameraMirror).apply();
    }

    public static boolean isDataMirror() {
        return sp().getBoolean("dataMirror", false);
    }

    public static void setDataMirror(boolean dataMirror) {
        sp().edit().putBoolean("dataMirror", dataMirror).apply();
    }

    public static boolean isOpenLive() {
        return sp().getBoolean("isOpenLive", false);
    }

    public static void setOpenLive(boolean openLive) {
        sp().edit().putBoolean("isOpenLive", openLive).apply();
    }

    public static int getThreshold() {
        return sp().getInt("threshold", 80);
    }

    public static void setThreshold(int threshold) {
        sp().edit().putInt("threshold", threshold).apply();
    }

    public static int getVideoDirection() {
        return sp().getInt("videoDirection", 0);
    }

    public static void setVideoDirection(int videoDirection) {
        sp().edit().putInt("videoDirection", videoDirection).apply();
    }

    public static boolean getRgbRevert() {
        return sp().getBoolean("rgbRevert", false);
    }

    public static void setRgbRevert(boolean rgbRevert) {
        sp().edit().putBoolean("rgbRevert", rgbRevert).apply();
    }

    public static int getMoveLeftOrRight() {
        return sp().getInt("moveLeftOrRight", 0);
    }

    public static void setMoveLeftOrRight(int moveLeftOrRight) {
        sp().edit().putInt("moveLeftOrRight", moveLeftOrRight).apply();
    }

    public static int getMoveUpOrDown() {
        return sp().getInt("moveUpOrDown", 0);
    }

    public static void setMoveUpOrDown(int moveUpOrDown) {
        sp().edit().putInt("moveUpOrDown", moveUpOrDown).apply();
    }

    public static int getCameraHeight() {
        return sp().getInt("cameraHeight", 640);
    }

    public static void setCameraHeight(int cameraHeight) {
        sp().edit().putInt("cameraHeight", cameraHeight).apply();
    }

    public static int getCameraWidth() {
        return sp().getInt("cameraWidth", 480);
    }

    public static void setCameraWidth(int cameraWidth) {
        sp().edit().putInt("cameraWidth", cameraWidth).apply();
    }

    public static float getFaceScale() {
        return sp().getFloat("faceScale", 1.0f);
    }

    public static void setFaceScale(float faceScale) {
        sp().edit().putFloat("faceScale", faceScale).apply();
    }
}
